package project.controllers;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;



public class DateFormatter {
	private static final Logger log = Logger.getLogger(DateFormatter.class);
	private ConsoleScanner console_scanner;
	private static final String DATE_FORMAT="yyyy.MM.dd";
	
	public DateFormatter(){
		console_scanner=ConsoleScanner.getInstance();
	}
	
	public Date formatDate(){
		String s=console_scanner.getData();
		SimpleDateFormat f = new SimpleDateFormat(DATE_FORMAT);
		Date date=new Date();
		
		try{
			 date = f.parse(s);
			 
			
			
		}catch(ParseException pe){
			log.error(Messager.WRONG_DATE_FORMAT);
			Printer.printMessage(Messager.WRONG_DATE_FORMAT);
		}
		
		return date;
	}
	
	
	
	public  String getString(){
		String s=console_scanner.getData();
		return s;
	}
	
	

	
}
